package com.ruoyi.project.bajiaostar.tOrderStayRecord.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.bajiaostar.tOrderStayRecord.domain.TOrderStayRecord;
import com.ruoyi.project.bajiaostar.tOrderStayRecord.service.ITOrderStayRecordService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 变更待结算记录Controller
 * 
 * @author 写烧糊
 * @date 2024-06-17
 */
@Controller
@RequestMapping("/bajiaostar/tOrderStayRecord")
public class TOrderStayRecordController extends BaseController
{
    private String prefix = "bajiaostar/tOrderStayRecord";

    @Autowired
    private ITOrderStayRecordService tOrderStayRecordService;

    @RequiresPermissions("bajiaostar:tOrderStayRecord:view")
    @GetMapping()
    public String tOrderStayRecord()
    {
        return prefix + "/tOrderStayRecord";
    }

    /**
     * 查询变更待结算记录列表
     */
    @RequiresPermissions("bajiaostar:tOrderStayRecord:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TOrderStayRecord tOrderStayRecord)
    {
        startPage();
        List<TOrderStayRecord> list = tOrderStayRecordService.selectTOrderStayRecordList(tOrderStayRecord);
        return getDataTable(list);
    }

    /**
     * 导出变更待结算记录列表
     */
    @RequiresPermissions("bajiaostar:tOrderStayRecord:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TOrderStayRecord tOrderStayRecord)
    {
        List<TOrderStayRecord> list = tOrderStayRecordService.selectTOrderStayRecordList(tOrderStayRecord);
        ExcelUtil<TOrderStayRecord> util = new ExcelUtil<TOrderStayRecord>(TOrderStayRecord.class);
        return util.exportExcel(list, "tOrderStayRecord",null);
    }

    /**
     * 新增变更待结算记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存变更待结算记录
     */
    @RequiresPermissions("bajiaostar:tOrderStayRecord:add")
    @Log(title = "变更待结算记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TOrderStayRecord tOrderStayRecord)
    {
        return toAjax(tOrderStayRecordService.insertTOrderStayRecord(tOrderStayRecord));
    }

    /**
     * 修改变更待结算记录
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TOrderStayRecord tOrderStayRecord = tOrderStayRecordService.selectTOrderStayRecordById(id);
        mmap.put("tOrderStayRecord", tOrderStayRecord);
        return prefix + "/edit";
    }

    /**
     * 修改保存变更待结算记录
     */
    @RequiresPermissions("bajiaostar:tOrderStayRecord:edit")
    @Log(title = "变更待结算记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TOrderStayRecord tOrderStayRecord)
    {
        return toAjax(tOrderStayRecordService.updateTOrderStayRecord(tOrderStayRecord));
    }

    /**
     * 删除变更待结算记录
     */
    @RequiresPermissions("bajiaostar:tOrderStayRecord:remove")
    @Log(title = "变更待结算记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tOrderStayRecordService.deleteTOrderStayRecordByIds(ids));
    }
}
